home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / ExcaliburFilms.ifs < prev    next >
Text File  |  2005-03-13  |  12KB  |  377 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=KaraGarga
  8. Title=Excalibur Films
  9. Description=Excalibur Films Adult DVD
  10. Site=http://alldvdmovies.com
  11. Language=EN
  12. Version=0.2 - 14.10.2004
  13. Requires=3.5.0
  14. Comments= ExcaliburFilms| Written by KaraGarga| karagarga@gmail.com| Script Date: 14.10.2004
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. program Excalibur;
  23.  
  24. const
  25.     ImportActors = True;
  26.     ImportBigCover = True;
  27.     ImportSmallCover = False;
  28.     ImportCustomerReview = True;
  29.     ImportReview = True;
  30.     ImportLenght = True;
  31.     { True: Related info will be parsed
  32.       False: Related info won't be parsed }
  33. var
  34.   MovieName: string;
  35.   MovieURL: string;
  36.  
  37. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  38. var
  39.   i: Integer;
  40. begin
  41.   result := -1;
  42.   if StartAt < 0 then
  43.     StartAt := 0;
  44.   for i := StartAt to List.Count-1 do
  45.     if Pos(Pattern, List.GetString(i)) <> 0 then
  46.     begin
  47.       result := i;
  48.       Break;
  49.     end;
  50. end;
  51.  
  52. function StringReplaceAll(S, Old, New: string): string;
  53. begin
  54.   while Pos(Old, S) > 0 do
  55.     S := StringReplace(S, Old, New);
  56.   Result := S;
  57. end;
  58.  
  59. procedure CutAfter(var Str: string; Pattern: string);
  60. begin
  61.   Str := Copy(str, Pos(Pattern, Str) + Length(Pattern), Length(Str));
  62. end;
  63.  
  64. procedure CutBefore(var Str: string; Pattern: string);
  65. begin
  66.   Str := Copy(Str, Pos(Pattern, Str), Length(Str));
  67. end;
  68.  
  69. function GetStringFromHTML(Page, StartTag, CutTag, EndTag: string): string;
  70. begin
  71.   Result := '';
  72.   if Pos(StartTag, Page) > 0 then begin
  73.     CutBefore(Page, StartTag);
  74.     if Length(CutTag) > 0 then
  75.       CutAfter(Page, CutTag);
  76.       Result := Copy(Page, 0, Pos(EndTag, Page) - 1);
  77.       HTMLDecode(Result);
  78.   end;
  79. end;
  80.  
  81. procedure AnalyzePage(Address: string);
  82. var
  83.   Page: TStringList;
  84. begin
  85.   Page := TStringList.Create;
  86.   Page.Text := GetPage(Address);
  87.   if pos('DVD Video Movie</TITLE>', Page.Text) > 0 then
  88.   begin
  89.     AnalyzeMoviePage(Page)
  90.   end;
  91.   if pos('<table width="430" align="center" cellpadding="0" cellspacing="0" hspace="0" border="0">', Page.Text) > 0 then
  92.   begin
  93.     PickTreeClear;
  94.     AddMoviesTitles(Page);
  95.     if PickTreeExec(Address) then
  96.     AnalyzePage(Address);
  97.   end;
  98.   if pos('Sorry, no DVD result matches your search.', Page.Text) > 0 then
  99.   begin
  100.   ShowMessage('Sorry, no DVD result matches your search. Please narrow your search criteria.');
  101.   if Input('Excalibur Films: Adult DVD Script 0.1', 'Please enter the title of the movie:', MovieName) then
  102.     begin
  103.       AnalyzePage('http://www.alldvdmovies.com/IndexS2.htm?SearchFor=Title.x&Search=AdultDVDMovies&Case=AllDVDMovies&x=0&y=0&searchString='+UrlEncode(MovieName));
  104.     end;
  105.   end;
  106.   Page.Free;
  107. end;
  108.  
  109. procedure AnalyzeMoviePage(Page: TStringList);
  110. var
  111.   Line, Value, Value2 : string;
  112.   LineNr: Integer;
  113.   BeginPos, EndPos : Integer;
  114. begin
  115.  
  116. // URL--------------------------------------------------------------------------
  117.   LineNr := FindLine('onCLick="location=', Page, 0);
  118.   Line := Page.GetString(LineNr);
  119.   if LineNr > -1 then
  120.   begin
  121.     BeginPos := pos('ck="', Line);
  122.     if BeginPos > 0 then
  123.       BeginPos := BeginPos + 14;
  124.     EndPos := pos('.htm', Line);
  125.     if EndPos = 0 then
  126.       EndPos := Length(Line);
  127.     Value := copy(Line, BeginPos, EndPos - BeginPos - 2);
  128.     HTMLDecode(Value);
  129.     SetField(fieldURL, 'http://excaliburfilms.com/AdultDVD/'+Value+'.htm');
  130.   end;
  131.  
  132.  
  133. //Title-------------------------------------------------------------------------
  134.   LineNr := FindLine('<h2><font color="Navy" class="size20bold">', Page, 0);
  135.   if LineNr > -1 then
  136.   begin
  137.     Value := Page.GetString(LineNr);
  138.     HTMLDecode(Value);
  139.     HTMLRemoveTags(Value);
  140.     SetField(fieldOriginalTitle, Value);
  141.   end;
  142.  
  143. //Sub-Title
  144.   LineNr := FindLine('<font color="Navy" class="size15">', Page, 0);
  145.   if LineNr > -1 then
  146.     begin
  147.     Value2 := Page.GetString(LineNr);
  148.     HTMLDecode(Value2);
  149.     HTMLRemoveTags(Value2);
  150.     SetField(fieldOriginalTitle, Value+' '+Value2);
  151.     end;
  152.   if LineNr < 0 then
  153.     begin
  154.     SetField(fieldOriginalTitle, Value)
  155.     end;
  156.  
  157. // Rating-----------------------------------------------------------------------
  158.   LineNr := FindLine('Customer Rating:</font>', Page, 0);
  159.   if LineNr > -1 then
  160.   begin
  161.     Line := Page.GetString(LineNr + 1);
  162.     if Pos('excal/Stars_', Line) > 0 then
  163.     begin
  164.       BeginPos := pos('Stars_', Line) + 6;
  165.       EndPos := pos('.gif"', Line);
  166.       Value := copy(Line, BeginPos, EndPos - BeginPos);
  167.       Value := StringReplace(Value, '-', ',');
  168.       SetField(fieldRating, Value);
  169.     end;
  170.   end;
  171.  
  172. // Director---------------------------------------------------------------------
  173.   LineNr := FindLine('Director: </font>', Page, 0);
  174.   if LineNr > -1 then
  175.   begin
  176.   Line := Page.GetString(LineNr);
  177.    BeginPos := pos('dana">', Line) + 6;
  178.    EndPos := pos('</FONT>', Line);
  179.       Value := copy(Line, BeginPos, EndPos - BeginPos);
  180.       HTMLDecode(Value);
  181.     SetField(fieldDirector, Value);
  182.   end;
  183.  
  184.  
  185. //Small Picture-----------------------------------------------------------------
  186.   if ImportSmallCover then
  187.     begin
  188.     LineNr := FindLine('<img src="http://images.excaliburfilms.com/dvd/reviews/', Page, 0);
  189.       if LineNr > -1 then
  190.         begin
  191.         Line := Page.GetString(LineNr);
  192.         BeginPos := pos('src="', Line) + 4;
  193.         Delete(Line, 1, BeginPos);
  194.         EndPos := pos('"', Line);
  195.         Value := copy(Line, 1, EndPos - 1);
  196.         HTMLDecode(Value);
  197.         GetPicture(Value);
  198.         end;
  199.     end;
  200.  
  201.  
  202. //Big Picture-------------------------------------------------------------------
  203.   if ImportBigCover then
  204.     begin
  205.     LineNr := FindLine('<img src="http://images.excaliburfilms.com/dvd/reviews/', Page, 0);
  206.     if LineNr > -1 then
  207.       begin
  208.       Line := Page.GetString(LineNr);
  209.       BeginPos := pos('src="', Line) + 4;
  210.       Delete(Line, 1, BeginPos);
  211.       EndPos := pos('"', Line);
  212.       Value := copy(Line, 1, EndPos - 1);
  213.       Value := StringReplace(Value, 'T8/', 'T8/largemoviepic/');
  214.       Value := StringReplace(Value, '_dvd.jpg', '.JPG');
  215.       HTMLDecode(Value);
  216.       GetPicture(Value);
  217.       end;
  218.     end;
  219.  
  220. //Category----------------------------------------------------------------------
  221.   LineNr := FindLine('Rated: </font>', Page, 0);
  222.   if LineNr > -1 then
  223.   begin
  224.     Line := Page.GetString(LineNr);
  225.     BeginPos := pos('Rated: </font>', Line) + 14;
  226.     EndPos := pos('</a><BR>', Line);
  227.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  228.     HTMLRemoveTags(Value);
  229.     HTMLDecode(Value);
  230.     SetField(fieldCategory, Value);
  231.   end;
  232.  
  233. //Synopsis----------------------------------------------------------------------
  234.   LineNr := FindLine('Synopsis: </font>', Page, 0);
  235.   if LineNr > -1 then
  236.   begin
  237.     Value := Page.GetString(LineNr);
  238.     Value := StringReplace(Value, '<p>', #13#10);
  239.     Value := StringReplace(Value, 'Synopsis: ', '');
  240.     HTMLRemoveTags(Value);
  241.     HTMLDecode(Value);
  242.     SetField(fieldDescription, Value);
  243.   end;
  244.  
  245. // Excalibur Review-------------------------------------------------------------
  246.   if ImportReview then
  247.   begin
  248.   LineNr := FindLine('br clear="all"><font color="black" class="size14verdanabold">Themes:', Page, 0);
  249.   if LineNr > -1 then
  250.   begin
  251.     Value:= GetStringFromHTML(Page.Text, 'class="size14verdanabold">Themes: </font> ', '<font color="Black" class="size14verdana">', '<CENTER>');
  252.     Value := StringReplace(Value, '<br>', #13#10);
  253.     Value := StringReplace(Value, '<p>', #13#10);
  254.     Value := StringReplace(Value, '<P>', #13#10);
  255.     Value := StringReplace(Value, #13#10+' ', #13#10);
  256.     Value := StringReplace(Value, #13#10+#13#10, #13#10);
  257.     HTMLRemoveTags(Value);
  258.     HTMLDecode(Value);
  259.     SetField(fieldComments, Value);
  260.   end;
  261.   end;
  262.  
  263.  
  264. // Customer Review--------------------------------------------------------------
  265.   if ImportCustomerReview then
  266.   begin
  267.   LineNr := FindLine('Customer Reviews:</font>', Page, 0);
  268.   if LineNr > 0 then
  269.     begin
  270.     Value:= GetStringFromHTML(Page.Text, 'Customer Reviews:</font>', '<font color="Black" class="size14verdana">', '</td></tr></table>');
  271.     Value := StringReplace(Value, '<P>', #13#10+#13#10);
  272.     Value := StringReplace(Value, '<BR>', #13#10);
  273.     Value := StringReplace(Value, 'Customer Reviews:', '');
  274.     Value := StringReplace(Value, #13#10+#13#10, #13#10);
  275.     HTMLRemoveTags(Value);
  276.     HTMLDecode(Value);
  277.     SetField(fieldComments, GetField(fieldComments)+'CUSTOMER REVIEW(s):'+Value);
  278.     end;
  279.   end;
  280.  
  281.  
  282. // Length-----------------------------------------------------------------------
  283.   if ImportLenght then
  284.   LineNr := FindLine('Run Time: </font>', Page, 0);
  285.   if LineNr > -1 then
  286.   begin
  287.     Value := Page.GetString(LineNr);
  288.     HTMLRemoveTags(Value);
  289.     HTMLDecode(Value);
  290.     Value := StringReplace(Value, 'Run Time:', '');
  291.     Value := StringReplace(Value, ' ', '');
  292.     Value := StringReplace(Value, 'min.', '');
  293.     SetField(fieldLength, Value);
  294.   end;
  295.  
  296.  
  297. // Actors-----------------------------------------------------------------------
  298.   if ImportActors then
  299.   begin
  300.   LineNr := FindLine('Starring:</font>', Page, 0);
  301.   if LineNr > -1 then
  302.   begin
  303.    Value := Page.GetString(LineNr);
  304.    Value := StringReplace(Value, 'Starring:</font> ', '');
  305.    Value := StringReplace(Value, 'Starring:</font>', '');
  306.    HTMLRemoveTags(Value);
  307.    HTMLDecode(Value);
  308.    SetField(fieldActors, Value);
  309.   end;
  310.   end;
  311.  
  312. //Release Year------------------------------------------------------------------
  313.   LineNr := FindLine('Released: </font>', Page, 0);
  314.   if LineNr > -1 then
  315.   begin
  316.     Line := Page.GetString(LineNr);
  317.     BeginPos := pos('dana">', Line) + 6;
  318.     EndPos := pos(',', Line);
  319.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  320.     SetField(fieldYear, Value);
  321.   end;
  322.  
  323.   //DisplayResults;
  324. end;
  325.  
  326.  
  327. procedure AddMoviesTitles(Page: TStringList);
  328. var
  329.   Line, Result: string;
  330.   LineNr: Integer;
  331.   MovieTitle, MovieAddress: string;
  332.   StartPos: Integer;
  333. begin
  334.   LineNr := FindLine('<font class=searchTitle>', Page, 0);
  335.   if LineNr > -1 then
  336.   begin
  337.     LineNr:=FindLine('<font color="White"><b>Records:</b>', Page, 0);;
  338.     Result:= Page.GetString(LineNr+7);
  339.     StartPos := pos('<b>', Result) + 3;
  340.     Result := Copy(Result, StartPos, Pos('</b>', Result) - StartPos);
  341.     PickTreeAdd('Excalibur Films Search >> Number of Results: '+'('+Result+')', '');
  342.     LineNr := FindLine('<table width="430" align="center" cellpadding="0" cellspacing="0" hspace="0" border="0">', Page, 0);
  343.     LineNr := LineNr +2;
  344.     Line := Page.GetString(LineNr);
  345.     repeat
  346.       StartPos := Pos('onMouseout="window.status=''" title="DVD"><font class=searchTitle>', Line) + 1;
  347.       MovieTitle := Copy(Line, StartPos, Pos('</font></a><font class=searchTitle> DVD <a', Line) - StartPos);
  348.       HTMLRemoveTags(MovieTitle);
  349.       HTMLDecode(MovieTitle);
  350.       StartPos := pos('a href=', Line) + 7;
  351.       Delete(Line, 1, StartPos);
  352.       MovieAddress := Copy(Line, 1, pos('" onmouseover=', Line) - 1);
  353.       if MovieTitle <> '' then
  354.       PickTreeAdd(MovieTitle, MovieAddress);
  355.       LineNr := LineNr + 1;
  356.       Line := Page.GetString(LineNr);
  357.       until Pos('<p align="center">', Line) > 0;
  358.     end;
  359. end;
  360.  
  361. begin
  362.   if CheckVersion(3,5,0) then
  363.   begin
  364.     MovieName := GetField(fieldOriginalTitle);
  365.     if MovieName = '' then
  366.       MovieName := GetField(fieldTranslatedTitle);
  367.     if Input('Excalibur Films: Adult DVD Script 0.1', 'Please enter the title of the movie:', MovieName) then
  368.     begin
  369.       AnalyzePage('http://www.alldvdmovies.com/IndexS2.htm?SearchFor=Title.x&Search=AdultDVDMovies&Case=AllDVDMovies&x=0&y=0&searchString='+UrlEncode(MovieName));
  370.     end;
  371.   end
  372.   else
  373.   ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  374. end.
  375.  
  376.  
  377.